﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public class ActorFactory : IInitByGameLevel,IDispose
{
    public Actor CreateMarkOne() 
    {
        /*
         * level1:
         *      CreateEmptyActor
         * level2:
         *      CreateHelper
         *      CreateAttribute
         * Level3:
         *      InitAttributeStartData
         */
        var actorMarkOne = this.CreateActorEmpty();
        
        actorMarkOne.Name = "MarkOne here..";
        actorMarkOne.SetHelper(EnumHelper.LogSelfHelper,new LogSelfHelper());
        actorMarkOne.SetAttribute(EnumAttributeItem.Transform,new TransformAttribute());
        actorMarkOne.SetAttribute(EnumAttributeItem.BattleCharactor, new BattleCharactorAttribute());
        actorMarkOne.SetAttribute(EnumAttributeItem.Movement, new MovementAttribute());

        AttributeConfigUtil.LoadAttributeFromJson(actorMarkOne, EnumAttributeItem.Transform, "MarkOne_StartTransform.json");
        AttributeConfigUtil.LoadAttributeFromJson(actorMarkOne, EnumAttributeItem.BattleCharactor, "MarkOne_StartBattleCharactor.json");
        AttributeConfigUtil.LoadAttributeFromJson(actorMarkOne, EnumAttributeItem.Movement, "MarkOne_StartMovement.json");

        return actorMarkOne;    
    }
    public void RecycleActor(Actor actor) 
    {
        actor.Dispose();
    }

    private Actor CreateActorEmpty() 
    {
        Actor actor = new Actor();
        actor.InitByGameLevel(_curGameLevelMg);
        return actor;
    }

    private uint curLastActorIdent = 0;
    public uint GenActorIdent() 
    {
        return curLastActorIdent++;
    }

    public void InitByGameLevel(IGGameLevelMgr gameLevel)
    {
        _curGameLevelMg = gameLevel;
    }

    public void Dispose()
    {
        _curGameLevelMg = null;
    }

    private IGGameLevelMgr _curGameLevelMg;
}

